package com.alpesressources.comexpert.bo.response;

public class ErrorResponse {

	public enum EnumErrorCode {
		NO_ERROR(0, "No error"), INVALID_QUERY_STRING(1,
				"Invalid query string, the action and dossier field are required"), INVALID_HASHKEY(
				2, "Invalid hashkey"), INVALID_TOKEN(3, "Invalid token"), EMPTY_MESSAGE(
				4, "Empty message"), INVALID_MESSAGE(5, "Invalid message"), INVALID_REQUEST_DATE(
				6, "Invalid request date");

		private Integer code;
		private String message;

		private EnumErrorCode(Integer code, String message) {
			this.code = code;
			this.message = message;
		}

		public Integer getCode() {
			return code;
		}

		public String getMessage() {
			return message;
		}

		public static EnumErrorCode fromInteger(Integer code) {
			for (EnumErrorCode e : EnumErrorCode.values()) {
				if (e.equals(code)) {
					return e;
				}
			}

			return null;
		}
	}

	private EnumErrorCode errorCode;

	public String getMessage() {
		return errorCode.getMessage();
	}

	public EnumErrorCode getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(EnumErrorCode errorCode) {
		this.errorCode = errorCode;
	}

	@Override
	public String toString() {
		return "ErrorResponse [errorCode=" + errorCode + "]";
	}

}
